package com.best.onegous;

import java.util.LinkedList;

import com.best.onegous.viewutils.ToastView;
import com.readystatesoftware.systembartint.SystemBarTintManager;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.support.v4.app.FragmentActivity;
import android.view.Gravity;
import android.view.WindowManager;
import android.widget.Toast;

public class BaseActivity extends FragmentActivity {

	public static LinkedList<Activity> allActivitys = new LinkedList<Activity>();
	ToastView toast;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		allActivitys.add(this);
	}

	  public  void setC(int layoutResID){
		   	 if(VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
		            //͸��״̬��
		            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//		            //͸��������
		            //getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
		        }
		    	setContentView(layoutResID);
		    
		    	
			        
		   }
	 public  void setThem(int layoutResID){
		 if(VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
             //͸��״̬��
             getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//             //͸��������
            // getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
         }
     	setContentView(layoutResID);
     	SystemBarTintManager tintManager = new SystemBarTintManager(this);
         tintManager.setStatusBarTintEnabled(true);
         tintManager.setNavigationBarTintEnabled(true);
         tintManager.setNavigationBarAlpha(1);
         tintManager.setNavigationBarTintColor(Color.parseColor("#00000000"));
         
         tintManager.setStatusBarTintColor(Color.parseColor("#E9CDA6"));
    	
    }
	 public  void setCc(int layoutResID){
    	 setContentView(layoutResID);
    }
	 
	@Override
	public void setContentView(int layoutResID) {
		// TODO Auto-generated method stub
		super.setContentView(layoutResID);

	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		allActivitys.remove(this);
	}

	@Override
	public void startActivity(Intent intent) {
		super.startActivity(intent);
	    overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
	}

	@Override
	public void finish() {
		super.finish();
		overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
	}

	public static void finishAll() {
		for (Activity activity : allActivitys) {
			activity.finish();
		}
		allActivitys.clear();
		// �����Ҫ�������رս�̵�, �������activity
		// finish�Ļ�������ǲ���رյ�
		System.exit(0);
		// android.os.Process.killProcess(android.os.Process.myPid());
	}

	@SuppressLint("ShowToast")
	public void toast(String text) {
		toast = new ToastView(this, text);
      	toast.setGravity(Gravity.CENTER, 0, 0);
          toast.show();

	}

}
